<template>
  <div class="demo-page">
    <div class="demo-header">
      <h1>币种选择器演示</h1>
      <p>点击下方按钮打开币种选择器</p>
    </div>

    <div class="demo-content">
      <div class="current-currency">
    <h3>当前选择的币种：</h3>
        <div v-if="selectedCurrency" class="currency-display">
          <div class="currency-symbol">{{ selectedCurrency.symbol }}/USDT</div>
          <div class="currency-price">{{ selectedCurrency.price }}</div>
          <div 
            :class="[
              'currency-change',
              selectedCurrency.change >= 0 ? 'positive' : 'negative'
            ]"
          >
            {{ selectedCurrency.change >= 0 ? '+' : '' }}{{ selectedCurrency.change }}%
          </div>
        </div>
        <div v-else class="no-selection">
          请选择币种
        </div>
      </div>

      <div class="demo-buttons">
        <button class="demo-btn" @click="showSelector = true">
          打开币种选择器
        </button>
      </div>
    </div>

    <!-- 币种选择器 -->
    <CurrencySelector 
      v-model:show="showSelector"
      @select="handleCurrencySelect"
    />
  </div>
</template>

<script setup>
import { ref } from 'vue'
import CurrencySelector from '@/components/CurrencySelector/index.vue'

const showSelector = ref(false)
const selectedCurrency = ref(null)

const handleCurrencySelect = (currency) => {
  selectedCurrency.value = currency
  console.log('选择的币种:', currency)
}
</script>

<style lang="scss" scoped>
.demo-page {
  min-height: 100vh;
  background: #f5f5f5;
  padding: 20px;
}

.demo-header {
  text-align: center;
  margin-bottom: 40px;
  
  h1 {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
  }
  
  p {
    color: #666;
    font-size: 14px;
  }
}

.demo-content {
  max-width: 600px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.current-currency {
  margin-bottom: 30px;
  
  h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 15px;
  }
}

.currency-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.currency-symbol {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.currency-price {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.currency-change {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  
  &.positive {
    background: #e8f5e8;
    color: #52c41a;
  }
  
  &.negative {
    background: #fff2f0;
    color: #ff4d4f;
  }
}

.no-selection {
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.demo-buttons {
  text-align: center;
}

.demo-btn {
  background: #1890ff;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  
  &:hover {
    background: #40a9ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
  }
  
  &:active {
    transform: translateY(0);
  }
}
</style> 